﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.BaseClass;
using Rotempco.BaseClass.Objects.Enums;
using Rotempco.Website.WebPages.Admin.Users.Extensions;
using Rotempco.Website.WebPages.Admin.Users.Managers;
using Rotempco.BaseClass.Objects.ReturnObjects;
using Rotempco.Website.Objects;
using Rotempco.Core.Web.CRUD.ACRUD;

namespace Rotempco.Website.WebPages.Admin.Users
{
    public partial class Edit : ACRUDEdit<LoginUserExtension, long>
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public override LoginUserExtension GetNewInstance()
        {
            return LoginUserExtensionManager.Instance.GetNewInstance();
        }

        public override string ValidateObject(LoginUserExtension loginUserExtension)
        {
            CreateNewLoginUserResultEnum createNewLoginUserResultEnum = Factory.LoginUser.ValidateNewLoginUser(loginUserExtension);

            switch (createNewLoginUserResultEnum)
            {
                case CreateNewLoginUserResultEnum.Success:
                    return null;
                case CreateNewLoginUserResultEnum.InvalidEmail:
                    return "Invalid email";
                case CreateNewLoginUserResultEnum.UserAllreadyExists:
                    return "Email allready exists";
                case CreateNewLoginUserResultEnum.PrivateDecryptionKeyStoreEmpty:
                default:
                    return "Error: User not created";
            }

        }
    }
}